/*cPb1BQxEZ8c0dGZlqiLjAJF08zfcR+CsS+JtIypBQKLw+Y6qTuYsiZsr6oPsBJfc*/
/*
 * @Descripttion: 多语&&模板资源统一查询
 * @version:
 * @Author: Chendch
 * @Date: 2021-06-09 10:26:49
 * @LastEditors: Chendch
 * @LastEditTime: 2021-10-09 18:40:40
 */
function getMultiLang(props, langCfg) {
    return new Promise( (resolve, reject) => {
        props.MultiInit.getMultiLang(
            {
                ...langCfg,
                callback: (json, status, inlt) => {
                    if(!status) {
                        return resolve({
                            langData: {},
                            init: {}
                        })
                    }
                    return resolve({
                        langData: json,
                        inlt
                    })
                }
            }
        )
    })
}

function getUIDom(props, pageCfg) {
    return new Promise( (resolve, reject) => {
        props.createUIDom(pageCfg, (data) => {
            return resolve({
                templateData: data
            })
        });
    })
}
/***
 * params:
 *  pageCfg: 页面模板查询参数
 *  langCfg：多语模板查询参数
 *  callback: 查询成功回调函数
 * return params:
 *  templateData: 模板数据
 *  langData: 多语
 *  inlt: 多语方法
 * ***/
export default function BDCreateUIDom(props){
    return ( pageCfg = {} , langCfg = {}, callback ) => {
        return Promise.all([getMultiLang(props, langCfg), getUIDom(props, pageCfg)]).then( (data) => {
            let virMap = new Map();
            data.forEach( item => {
                for(let key in item) {
                    virMap.set(key, item[key])
                }
            });
            console.log("555--", virMap);
            callback && callback(virMap.get("templateData"), virMap.get("langData"), virMap.get("inlt"))
        })
    };
};
/*cPb1BQxEZ8c0dGZlqiLjAJF08zfcR+CsS+JtIypBQKLw+Y6qTuYsiZsr6oPsBJfc*/
